package arduino.controller.action;

import java.io.IOException;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchWindow;

import arduino.eithernet.connection.EithernetConnectionManager;

/**
 * Opens an &quot;About RAP&quot; message dialog.
 */
public class AboutAction extends Action {

    private final IWorkbenchWindow window;

    public AboutAction(IWorkbenchWindow window) {
	super("About");
	setId(this.getClass().getName());
	this.window = window;
    }

    public void run() {
	if (window != null) {
	    String title = "Eithernet Connection";
	    String msg = "";
	    EithernetConnectionManager connection = new EithernetConnectionManager();
	    try {
		msg = connection.connectToArduino("/arduinodummy/getTime.html");
	    } catch (IOException e) {
		e.printStackTrace();
	    }
	    MessageDialog.openInformation(window.getShell(), title, msg);
	}
    }
}
